home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u200.dms / in.adf / NIALL.AMOS / NIALL.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1992-04-24  |  9.1 KB  |  254 lines

  1. Rem ******************************************************************** 
  2. Rem **    NIALL  Non-Intelligent AMOS Language Learner Version 1.0    ** 
  3. Rem **   ==========================================================   ** 
  4. Rem **                Written By Matthew Peck in 1990                 **           
  5. Rem ******************************************************************** 
  6. Set Buffer 120
  7. MNW=3000
  8. Randomize Timer
  9. Hide On : Close Editor 
  10. Close Workbench 
  11. Dim WORD$(MNW,1),W$(255),CO(1)
  12. Global COM,T$,WORD$(),NUM,W$(),W,SPEAK,HARD,CO(),MNW
  13. WORD$(0,0)=" " : WORD$(MNW,0)="."
  14. SETUP
  15. Do 
  16.    USER_INPUT
  17.    If COM=1 Then Goto SKIPIT
  18.    NIALL_REPLIES
  19.    SKIPIT:
  20. Loop 
  21. Rem -------------------------------------------------------------------- 
  22. Procedure SEE_INSTRUCTIONS
  23.    Screen Hide 1 : Screen Hide 0
  24.    For F=1 To 2 : Unpack 2 To 2 : Gr Writing 0
  25.       For G=1 To 25 : Read C,A$ : Ink 0 : Text 17,33+G*8,A$
  26.          Ink C : Text 16,32+G*8,A$
  27.    Next G : Wait Key : Fade 2 : Wait 30 : Next F
  28.    Screen Close 2
  29.    Screen Show 1 : Screen Show 0
  30.    Data 6,"                               COMMAND WORDS"
  31.    Data 1," "
  32.    Data 1," When you are given the prompt USER: you will normally type in  a  sentence,"
  33.    Data 1,"but you can also type in a command word.    All command words  are  prefixed"
  34.    Data 1,"by a '#'.  This version (1.0) can support the following commands."
  35.    Data 1," "
  36.    Data 7,"#LIST        Displays Nialls current dictionary on the screen."
  37.    Data 1," "
  38.    Data 7,"#LLIST       Outputs the dictionary to a printer."
  39.    Data 1," "
  40.    Data 7,"#LPRINT      Toggles direct output to printer."
  41.    Data 1," "
  42.    Data 7,"#SPEAK       Toggles speech."
  43.    Data 1," "
  44.    Data 7,"#SAVE        Saves the current dictionary to disc under any name."
  45.    Data 1," "
  46.    Data 7,"#LOAD        Loads a previously saved dictionary from disc."
  47.    Data 1," "
  48.    Data 7,"#CORRECT     Corrects a mispelt word in the dictionary."
  49.    Data 1," "
  50.    Data 7,"#FRESH       Clears the current dictionary."
  51.    Data 1," "
  52.    Data 7,"#QUIT        Leaves the program."
  53.    Data 1," "
  54.    Data 5,"                                PRESS A KEY"
  55.    Data 5,"                                  CREDITS"
  56.    Data 1," "
  57.    Data 4,"         Written by Matthew Peck in AMOS Version 1.1 in August 1990"
  58.    Data 1,"  The original idea for NIALL was adapted from a program called DANI, which"
  59.    Data 1,"was written for the MSX machines and published in a magazine,MSX Computing."
  60.    Data 1,"NIALL is a complete re-write but I would like to give credit to the  author"
  61.    Data 1,"of DANI for the inspiration.  However, I no longer have the magazine and do"
  62.    Data 1,"not know the author's name. If you wrote DANI then contact me so that I can"
  63.    Data 1,"place your name in the credit list."
  64.    Data 1," "
  65.    Data 1,"  Many thanks go to the following people for their help, suggestions etc."
  66.    Data 6,"Adam Wright................................For waiting for me to code this."
  67.    Data 6,"Pat Fox and Julian Brown.....For playtesting my BBC basic version to death."
  68.    Data 6,"Kevin Tye...................................For being a generally nice guy."
  69.    Data 6,"Gary Keogh...............For being a great room-mate and friend at college."
  70.    Data 6,"Francios Lionet........................For AMOS, what else, and finally to "
  71.    Data 6,"Sarah Gould...........For being such a caring and understanding girlfriend."
  72.    Data 1," "
  73.    Data 1,"My address is:"
  74.    Data 4,"      23 Welbeck Avenue, Bedgrove, Aylesbury, Bucks, ENGLAND, HP21 9BH."
  75.    Data 1," Contact me with/for ideas, programs, NIALL dictionaries and NIALL updates."
  76.    Data 1," "
  77.    Data 5,"                                PRESS A KEY"
  78.    Data 1," "
  79.    Data 5,"                        AMOS (c) 1990 Mandarin/Jawx"
  80. End Proc
  81. Procedure USER_INPUT
  82.    COM=0 : For F=1 To 3 : Print : Next F : For F=1 To 3 : Cup : Next F
  83.    Pen CO(1) : Print "USER:"; : Pen 1 : Line Input " ";T$
  84.    Cup : Pen CO(1) : Print "USER: "; : Pen 1 : Print T$
  85.    If HARD=1 Then Lprint " USER:";T$
  86.    If T$="" Then Pop Proc
  87.    T$=Lower$(T$)
  88.    Rem --- Is it a command string --- 
  89.    If Left$(T$,1)="#" Then COMMANDS : COM=1 : Pop Proc
  90.    Rem --- Cuts out the rubbish --- 
  91.    R$="" : For F=1 To Len(T$)
  92.       If Mid$(T$,F,1)="," Then Mid$(T$,F,1)="."
  93.       If Instr("!�$%^&*()_+|}{@?></#\="+Chr$(34),Mid$(T$,F,1))=0 Then R$=R$+Mid$(T$,F,1)
  94.    Next F : T$=R$
  95.    Rem --- Seperates into words --- 
  96.    If Right$(T$,1)="." Then Right$(T$,1)=" "
  97.    Q$=T$
  98.    FULLSTOP:
  99.    If Instr(Q$,".")<>0 Then FS=1 : T$=Left$(Q$,Instr(Q$,".")-1) : Q$=Right$(Q$,Len(Q$)-Instr(Q$,"."))
  100.    W=1 : W$(W)="" : For F=1 To Len(T$)
  101.       If Mid$(T$,F,1)=" " Then If Mid$(T$,F+1,1)<>" " Then W=W+1 : W$(W)="" : Goto SKIP
  102.       W$(W)=W$(W)+Mid$(T$,F,1)
  103.    SKIP: Next F
  104.    If NUM<>MNW-1
  105.       ANALYSE_SENTENCE
  106.    End If 
  107.    If FS=1 Then FS=0 : T$=Q$ : Goto FULLSTOP
  108. End Proc
  109. Procedure ANALYSE_SENTENCE
  110.    Rem --- Loop for the number of words +1 ---
  111.    OLD=0
  112.    For H=1 To W+1
  113.       If H=W+1 Then F=MNW : Goto FOUNDIT
  114.       For F=1 To NUM : If W$(H)=WORD$(F,0) Then Goto FOUNDIT
  115.       Next F
  116.       Rem --- The word is a new one ---
  117.       NUM=NUM+1 : WORD$(NUM,0)=W$(H) : F=NUM
  118.       FOUNDIT:
  119.       If WORD$(OLD,1)="" Then WORD$(OLD,1)="1|"+Str$(F)+"(1)" : Goto ALLDONE
  120.       C$=WORD$(OLD,1) : C$=Str$(Val(C$)+1)+Right$(C$,Len(C$)-Instr(C$,"|")+1)
  121.       For G=Instr(C$,"|")+1 To Len(C$)
  122.          If Val(Right$(C$,Len(C$)-G))=F Then Goto HERE
  123.          G=Instr(C$,")",G)
  124.       Next G
  125.       C$=C$+Str$(F)+"(1)" : WORD$(OLD,1)=C$ : Goto ALLDONE
  126.       HERE:
  127.       G=Instr(C$,"(",G) : I=Instr(C$,")",G)-1
  128.       C$=Left$(C$,G)+Str$(Val(Right$(C$,Len(C$)-G))+1)+Right$(C$,Len(C$)-I)
  129.       WORD$(OLD,1)=C$
  130.       ALLDONE:
  131.       OLD=F
  132.    Next H
  133. End Proc
  134. Procedure NIALL_REPLIES
  135.    If NUM=0 Then Pen CO(1) : Print "I cannot speak yet!" : Pen 1 : Pop Proc
  136.    REP$="" : C=0
  137.    RLOOP:
  138.    C$=WORD$(C,1) : R=Rnd(Val(C$)) : If R=0 Then Goto RLOOP
  139.    For G=Instr(C$,"(") To Len(C$)
  140.       R=R-Val(Right$(C$,Len(C$)-G)) : If R<=0 Then Goto THISWORD
  141.       G=Instr(C$,"(",G+1)-1
  142.    Next G
  143.    End 
  144.    THISWORD:
  145.    For F=G To 1 Step -1
  146.       F$=Mid$(C$,F,1) : If(F$=")") or(F$="|") Then Goto WORD
  147.    Next F
  148.    WORD:
  149.    D=Val(Right$(C$,Len(C$)-F))
  150.    REP$=REP$+WORD$(C,0)+" "
  151.    C=D : If C<>MNW Then Goto RLOOP
  152.    Do 
  153.       If Left$(REP$,1)<>" " Then Exit 
  154.       REP$=Right$(REP$,Len(REP$)-1)
  155.    Loop 
  156.    If REP$="" Then Pop Proc
  157.    Left$(REP$,1)=Chr$(Asc(Left$(REP$,1))-32)
  158.    Right$(REP$,1)="."
  159.    Pen CO(1) : Print "NIALL:"; : Pen 1 : Print REP$
  160.    If SPEAK=1 Then Say REP$,0
  161.    If HARD=1 Then Lprint "NIALL:";REP$
  162. End Proc
  163. Procedure SETUP
  164.    If Fast Free<>0
  165.       Unpack 1 To 0 : Screen Display 0,128,40,320,28
  166.    End If 
  167.    If Fast Free<>0
  168.       Screen Open 1,640,230,4,Hires : CO(0)=2 : CO(1)=3
  169.    Else 
  170.       Screen Open 1,320,230,2,Lowres : CO(0)=1 : CO(1)=1
  171.    End If 
  172.    Screen Display 1,128,70,, : Flash Off : Screen 1 : Palette $0,$FFF,$F00,$48
  173.    Pen CO(0) : Paper 0 : Cls 
  174.    Centre "Welcome to NIALL" : Print 
  175.    Centre "Non Intelligent AMOS Language Learner" : Print 
  176.    Centre "Written in AMOS Basic Version 1.1" : Print 
  177.    Centre "by Matthew Peck in 1990" : Print : Print 
  178.    Centre "This program is fully Public Domain" : Print : Print 
  179.    If Fast Free<>0
  180.       Centre "Would you like further instructions (Y/N)" : A$=Input$(1) : Print 
  181.       A$=Upper$(A$)
  182.       If A$="Y"
  183.          SEE_INSTRUCTIONS
  184.       End If 
  185.       Centre ".......... Get Typing ..........."
  186.    End If 
  187.    Print 
  188. End Proc
  189. Procedure COMMANDS
  190.    If T$="#list"
  191.       For F=0 To NUM Step 20
  192.          For G=0 To 19 : If F+G<=NUM
  193.                Print F+G,WORD$(F+G,0),WORD$(F+G,1)
  194.             End If 
  195.          Next G : Print : Pen CO(0) : Centre "PRESS A KEY" : Pen 1 : Print : Wait Key 
  196.       Next F : Pop Proc
  197.    End If 
  198.    If T$="#llist"
  199.       For F=0 To NUM : Lprint F,WORD$(F,0),WORD$(F,1) : Next F
  200.    End If 
  201.    If T$="#save"
  202.       Show On : A$=Fsel$("df0:*.NIALL") : Hide On 
  203.       If Upper$(Right$(A$,6))<>".NIALL"
  204.          A$=A$+".NIALL"
  205.       End If 
  206.       Open Out 1,A$ : Print #1,NUM
  207.       For F=0 To NUM : Print #1,WORD$(F,0) : Print #1,WORD$(F,1) : Next F
  208.       Close 1
  209.    End If 
  210.    If T$="#load"
  211.       Show On : A$=Fsel$("df0:*.NIALL") : Hide On : Open In 1,A$
  212.       Input #1,NUM
  213.       Y=Y Curs
  214.       For F=0 To NUM : Locate 0,Y : Print "Countdown:";NUM-F;"  "; : Input #1,WORD$(F,0) : Input #1,WORD$(F,1) : Next F
  215.       Close 1
  216.       Print 
  217.    End If 
  218.    If T$="#correct"
  219.       Pen CO(0) : Print "Enter incorrect word:"; : Pen 1 : Input " ";O$
  220.       For F=1 To NUM
  221.          If Lower$(O$)=WORD$(F,0)
  222.             Pen CO(0) : Print "Enter correct spelling:"; : Pen 1 : Input " ";N$
  223.             WORD$(F,0)=Lower$(N$)
  224.          Else 
  225.          Next F : Print "Cannot find word ";O$
  226.       End If 
  227.    End If 
  228.    If T$="#fresh"
  229.       Pen CO(0) : Centre "Are you sure (Y/N)" : A$=Input$(1) : Print 
  230.       If Upper$(A$)="Y"
  231.          For F=0 To NUM : WORD$(F,0)="" : WORD$(F,1)="" : Next F : NUM=0
  232.       End If 
  233.    End If 
  234.    If T$="#quit"
  235.       Pen CO(0) : Centre "Do you really want to quit (Y/N)" : A$=Input$(1) : Print 
  236.       If Upper$(A$)="Y"
  237.          Screen Close 0 : Screen Close 1 : End 
  238.       End If 
  239.    End If 
  240.    If T$="#speak"
  241.       If SPEAK=0
  242.          SPEAK=1
  243.       Else 
  244.          SPEAK=0
  245.       End If 
  246.    End If 
  247.    If T$="#lprint"
  248.       If HARD=0
  249.          HARD=1
  250.       Else 
  251.          HARD=0
  252.       End If 
  253.    End If 
  254. End Proc